From: johnbob@loopback.uucp (John Harvey) Newsgroups: alt.sources Subject: makebait 01/01 -- Generate HTML containing bogus addresses Followup-To: alt.sources.d Date: 14 Oct 1996 23:35:01 GMT Organization: TheCompany Submitted by: johnbob Archive-name: makebait #!/usr/bin/perl -- -*-Perl-*- # # Generate HTML containing bogus addresses # The idea is to keep SPAMers and junkmailers who search web pages # for addresses too busy with bogus addresses to flood valid ones. # No good web site should be without a few thousand bogus addresses # that are changed often. # $verbose=0; $body_only=0; $title='SPAM bait'; $n_low=900; $n_high=1100; @candidate_list = ( 'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz0123456789', 'abcdefghijklmnopqrstuvwxyz0123456789', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', ); @candidate_list_p = ( 844, 125, 25, 5, 1, ); @name_length_p = ( 1, 49, 100, 150, 150, 125, 100, 75, ); @parts_p = ( 7, 2, 1, ); @ending_list = ( 'com', 'edu', 'org', 'gov', 'us', 'fi', ); @ending_list_p = ( 40, 30, 10, 1, 1, 1, ); %options = ( '-v', '$verbose=1;', '-h', '&do_help;', '-b', '$body_only=1;', '-t', '$title=shift(@ARGV);', '-n', '$n_low=shift(@ARGV);$n_high=$n_low;', ); sub do_help { print "-v turn on verbose mode\n"; print "-h help\n"; print "-b generate html body only, not an entire file\n"; print "-n v how many addresses to generate\n"; } srand(time|$$); if ( (@ARGV) ) { while( $arg=shift(@ARGV) ) { if( defined( $options{$arg} ) ) { eval $options{$arg}; } else { &generate_to_file($arg); } } } else { &do_help; } exit 0; sub generate_to_file { local($fname) = @_; if( ! open(OF,">$fname") ) { return; } if( ! $body_only ) { print OF " $title "; } else { print OF "\n"; } print OF "

$title

"; # postmaster@localhost local($n_mailto) = &integer_from_to($n_low,$n_high); $verbose && print "$n_mailto\n"; for(local($i)=0;$i<$n_mailto;$i++) { $address = &fake_address; $verbose && print "[$address]\n"; print OF "$address\n"; } if( ! $body_only ) { print OF " "; } else { print OF "\n"; } close(OF); } sub integer_from_to { local($from,$to) = @_; # $verbose && print "integer_from_to $from,$to\n"; if( $from == $to ) { return $from; } if( $from > $to ) { return &integer_from_to($to,$from); } local($diff) = ($to-$from)+1; local($rv)=$from+int(rand($diff)); # $verbose && print "rv=[$rv]\n"; return $rv; } sub integer_p_function { local(@p) = @_; local($total_volume) = 0; local($v); foreach $v ( @p ) { $total_volume += $v; } local($volume) = int(rand($total_volume)); local($rv) = 0; local($sum) = 0; foreach $v ( @p ) { $sum += $v; if( $volume < $sum ) { return $rv; } $rv++; } # this should never be reached return ($rv-1); } sub fake_address { local($parts) = &integer_p_function(@parts_p) + 1; local($index)=&integer_p_function(@candidate_list_p); local($candidates) = $candidate_list[$index]; #local($rv) = &random_name($candidates,1,8) . '@' . &random_name($candidates,1,8) . '.com'; local($rv) = &random_name_p($candidates) . '@' . &random_name_p($candidates); for(local($i)=1;$i<$parts;$i++) { $rv .= '.' . &random_name_p($candidates); } $index=&integer_p_function(@ending_list_p); $rv .= '.' . $ending_list[$index]; return $rv; } sub random_name { local($candidates,$from,$to) = @_; local($rv) = ''; local($a,$b) = split(/ /,$candidates); if( ! defined($b) ) { $b = $a; } local($length) = &integer_from_to($from,$to); if( $length < 1 ) { return $rv; } $rv .= &random_letter($a); for(local($i)=1;$i<$length;$i++) { $rv .= &random_letter($b); } return $rv; } sub random_name_p { local($candidates) = @_; local($rv) = ''; local($a,$b) = split(/ /,$candidates); if( ! defined($b) ) { $b = $a; } local($length)= &integer_p_function(@name_length_p) + 1; if( $length < 1 ) { return $rv; } $rv .= &random_letter($a); for(local($i)=1;$i<$length;$i++) { $rv .= &random_letter($b); } return $rv; } sub random_letter { local($candidates) = @_; return substr($candidates,&integer_from_to(0,length($candidates)-1),1); } -- John Harvey Email advertisers: put me on your "don't call, don't email" list. home: John_Harvey @acm .org johnbob@io. com http://www .io. com/~johnbob/